package com.sayice.design.Visitor;

import java.util.Iterator;

public class ListVisitor extends Visitor{

    @Override
    public void visit(Lei l) {
        System.out.println("类名："+l.getName());
        System.out.println("类代码行数:"+l.amount());
        Iterator it = l.iterator();
        while(it.hasNext()){
            Entry entry=(Entry) it.next();
            if(entry instanceof Fangfa){
                System.out.println("方法名:"+entry.getName());
                System.out.println("方法代码行数:"+entry.amount());
            }else{
                System.out.println("属性名:"+entry.getName());
            }
        }
    }

    @Override
    public void visit(Shuxing s) {
        System.out.println("属性名:"+s.getName());
    }

    @Override
    public void visit(Fangfa f) {
        System.out.println("方法名:"+f.getName());
        System.out.println("方法代码行数:"+f.amount());
    }
}
